package algorithms.que11;

/**
 * @功能
 * @创建时间 2020/6/7
 */
public class que33_Matrix {
    // 向量点乘
    public static double dot(double[] x,double[] y){
        double a=0;
        if(x.length!=y.length)
            return a;
        // 求各点的和
        for (int i=0;i<x.length;i++)
            a+=x[i]*y[i];
        return a;
    }
    //数组转置
    public static int[][] transpose(){
        int[][] a=  new int[2][3];
        for(int i=0;i<2;i++)
            for (int j=0;j<3;j++)
                a[i][j]=j;
            int[][] b = new int[3][2];
        for(int i=0;i<2;i++)
            for (int j=0;j<3;j++)
                b[j][i] =a[i][j];
        System.out.println(b[2][1]);
        System.out.println(a[1][2]);
        return b;
    }
    //矩阵的乘积
    static int[][] mult(int[][] a,int[][] b){
        int M=a[0].length;
        int N =a.length;
        int P=b[0].length;
        int[][] c = new int[M][P];
        if(M!=b.length)
        {

        }
        for (int i=0;i<N;i++)
            for (int j=0;j<P;j++)
            {
                for(int m=0;m<M;m++)
                    c[i][j]+=a[i][m]*b[m][j];
            }
        return c;

    }
    // 矩阵的向量乘积
    static double[] mult(double[][] a,double[] x) {
        int N = a.length;
        double[] c=new double[N];
        int M=a[0].length;
        if(M!=x.length){}
        for(int i=0;i<N;i++)
        {
            for (int m=0;m<M;m++)
                c[i]+=a[i][m]*x[m];
        }
        return c;
    }
    // 向量和矩阵乘积
    static double[] mult(double[] y,double[][] a){
        int N=y.length;
        double[] c=new double[N];
        int M=a[0].length;
        if(M!=a.length){}
        for(int i=0;i<N;i++){
            {
                for(int m=0;m<M;m++)
                    c[i]+=a[i][m]*y[i];
            }
        }
        return c;
    }
}
